var URL = 'http://114.142.153.146:8080/ad/epg.js';
function init(){
	if(document.persisted) {
		return false;
	}
	var btnBox = document.getElementById('btnBox');
	var aList = btnBox.getElementsByTagName('a');
	var a;
	for(var i = 0;i<aList.length;i++){
		a = aList[i];
		a.onfocus = focusItem;
		a.onclick = clickItem;
		a.onblur = blurItem;
	}
	aList[0].focus();
}

function focusItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'curBtn';
}

function blurItem(event){
	var a = event.currentTarget;
	var par = a.parentNode;
	par.className = 'btn';
}

function clickItem(event){
	var a = event.currentTarget;
	var tar = a.getAttribute("tar");
	if(tar =='text'){
		ajaxText();
	}else if(tar =='json'){
		ajaxJson();
	}
}

function ajaxText(){
	showGPointLoading(600,280);		//in utils
	
	$.ajax({					//in utils
		url:URL,
		success:function(text){
			hideGPointLoading();
			var tipBox = document.getElementById('tipBox');
			tipBox.innerHTML = text;
		},error:function(e){
			hideGPointLoading();
			var tipBox = document.getElementById('tipBox');
			tipBox.innerHTML = "Run programListener error....";
		}
	});
}

function ajaxJson(){
	showGPointLoading(600,280);		//in utils
	KEY.PRESS = false;				//
	$.ajax({					//in utils
		url:URL,
		dataType:'json',
		success:function(data){
			KEY.PRESS = true;
			hideGPointLoading();
			var tipBox = document.getElementById('tipBox');
			tipBox.innerHTML = data.toJSON();
		},error:function(e){
			KEY.PRESS = true;
			hideGPointLoading();
			var tipBox = document.getElementById('tipBox');
			tipBox.innerHTML = "Run programListener error....";
		}
	});
}